package com.weixing.mall.provider.controller.admin;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.weixing.mall.base.wrapper.Result;
import com.weixing.mall.base.wrapper.ResultUtil;
import com.weixing.mall.core.support.BaseController;
import com.weixing.mall.provider.model.enums.BillTransTypeEnum;
import com.weixing.mall.provider.model.enums.BillTypeEnum;
import com.weixing.mall.provider.model.query.AgentAccountBillQuery;
import com.weixing.mall.provider.model.query.AgentAccountQuery;
import com.weixing.mall.provider.model.vo.AgentAccountBillVo;
import com.weixing.mall.provider.model.vo.AgentAccountVo;
import com.weixing.mall.provider.service.IAgentAccountBillService;
import com.weixing.mall.provider.service.IAgentAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;


/**
 * 代理商账户相关接口
 *
 * @author sisahan
 * @since v1.0
 */
@RestController
@RequestMapping("agent/account")
public class AgentAccountController extends BaseController {

    @Autowired
    private IAgentAccountService agentAccountService;

    @Autowired
    private IAgentAccountBillService agentAccountBillService;

    /**
     * 代理账户信息
     *
     * @param query 查询条件
     * @return  查询结果
     */
    @GetMapping("")
    public Result<IPage<AgentAccountVo>> List(AgentAccountQuery query) {

        IPage<AgentAccountVo>  result= agentAccountService.findByAdmin(initMPage(),query);
        return ResultUtil.success(result);
    }

    /**
     * 代理商账户信息表--管理端用
     *
     * @param agentId    代理id
     * @param query      查询条件
     * @return           账户信息
     */
    @GetMapping("/billlist/{agentId}")
    public Result<IPage<AgentAccountBillVo>> billlist(@PathVariable Long  agentId ,AgentAccountBillQuery query) {
        IPage<AgentAccountBillVo>  result= agentAccountBillService.billList(initMPage(),agentId,query);
        return ResultUtil.success(result);
    }

    /**
     * 代理商账户查询枚举集合
     *
     * @return   枚举
     */
    @GetMapping("/accuontBillEnum")
    public  Result  accuontBillEnum(){
        Map<String ,Object> result= new HashMap<String,Object>();
        result.put("billTransType", BillTransTypeEnum.values());
        result.put("billType", BillTypeEnum.values());
        return  ResultUtil.success(result);
    }

}
